package com.tadpole.music.holder.question;

import android.view.View;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.question.SimulationBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/14
 */
public class SimulationViewHolder extends BaseViewHolder {
    private View itemView;
    private BaseAdapter.OnChildClickListener onChildClickListener;
    private List<SimulationBean.DataBeanX.DataBean> list;
    private TextView tvTitle;
    private TextView tvGo;

    public SimulationViewHolder(View itemView,BaseAdapter.OnChildClickListener onChildClickListener,List<SimulationBean.DataBeanX.DataBean> list) {
        super(itemView);
        this.itemView = itemView;
        this.onChildClickListener = onChildClickListener;
        this.list = list;
    }

    @Override
    public void init(final int position) {
        tvTitle = itemView.findViewById(R.id.tvTitle);
        tvTitle.setText(list.get(position).getName());
        tvGo = itemView.findViewById(R.id.tvGo);

        if(list.get(position).isPaid()){
            tvGo.setText("在线答题");
        }else{
            tvGo.setText("立即开通");
        }

        tvGo.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onChildClickListener.onChildClick(tvGo,position);
            }
        });
    }
}
